package sanglh.edu.hsphysics.main;

import java.util.ArrayList;

import sanglh.edu.hsphysics.R;
import sanglh.edu.hsphysics.base.BazeItem;
import sanglh.edu.hsphysics.formulas.FormulaItem;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

public class FragmentHighSchool extends FragmentNavigationDrawerItem {
	private static final String RES_NAME = "file_page";

	public FragmentHighSchool() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_highschool,
				container, false);
		loadData(rootView);
		return rootView;
	}

	@Override
	public String getTitle() {
		return getString(R.string.high_school);
	}

	private void loadData(View view) {
		GridView gvBook = (GridView) view.findViewById(R.id.gv);
		ArrayList<BazeItem> books = new ArrayList<BazeItem>();
		books.add(new FormulaItem(R.drawable.ic_physic_6, getResources()
				.getInteger(R.integer.physics_6_pages), RES_NAME, String
				.format("%s %s", getString(R.string.physics), "6")));
		books.add(new FormulaItem(R.drawable.ic_physic_7, getResources()
				.getInteger(R.integer.physics_7_pages), RES_NAME, String
				.format("%s %s", getString(R.string.physics), "7")));
		books.add(new FormulaItem(R.drawable.ic_physic_8, getResources()
				.getInteger(R.integer.physics_8_pages), RES_NAME, String
				.format("%s %s", getString(R.string.physics), "8")));
		books.add(new FormulaItem(R.drawable.ic_physic_9, getResources()
				.getInteger(R.integer.physics_9_pages), RES_NAME, String
				.format("%s %s", getString(R.string.physics), "9")));
		gvBook.setAdapter(new MenuAdapter(getActivity(), books,
				R.layout.row_book));
		gvBook.setOnItemClickListener(this);
	}

}
